package main

import (
	"log"
	"net/http"

	"github.com/gin-gonic/gin" // 替换为你使用的数据库驱动
	"swu.com/80p/internal/handlers"
)

func main() {
	r := gin.Default()

	r.GET("/healthz", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{"status": "ok"})
	})

	r.GET("/schema/:tableName", handlers.GetSchemaHandler)

	r.GET("/generic/:tableName", handlers.GetListHandler)
	r.GET("/generic/:tableName/:id", handlers.GetByIdHandler)
	r.POST("/generic/:tableName", handlers.CreateHandler)
	r.PUT("/generic/:tableName/:id", handlers.UpdateHandler)
	r.DELETE("/generic/:tableName/:id", handlers.DeleteHandler)

	if err := r.Run(":8080"); err != nil {
		log.Fatal("Failed to run server:", err)
	}
}
